<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="en">
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 后台大布局 - Layui</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/plugin/layui/css/layui.css">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    <jsp:include page="../module/top.jsp"></jsp:include>

    <jsp:include page="../module/left.jsp"></jsp:include>


    <div class="layui-body">
        <div style="padding: 15px;" id="content_div">
            <div class="layui-form" action="" lay-filter="example">
                <input type="hidden" name="id" id="id" value="${not empty blogType?blogType.id:""}">
                <div class="layui-form-item">
                    <label class="layui-form-label">分类名称</label>
                    <div class="layui-input-inline">
                        <input type="text" id="typeName" name="typeName" lay-verify="title" autocomplete="off"
                               placeholder="请输入标题" class="layui-input"
                               value="${not empty blogType?blogType.typeName:""}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" onclick="save()">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="../module/bottom.jsp"></jsp:include>
</div>
<script src="${pageContext.request.contextPath}/static/js/jquery-2.1.1.min.js"></script>
<script src="${pageContext.request.contextPath}/static/plugin/layui/layui.all.js"></script>
<script type="text/javascript">
    var form = layui.form;
    var layer = layui.layer;
    //监听提交
    function save() {
        var id = $("#id").val();
        var typeName = $("#typeName").val();
        var obj = {"id": id, "typeName": typeName}
        var jsonstr = JSON.stringify(obj);
        $.ajax({
            url: '${pageContext.request.contextPath}/blogtype/save_blogtype',
            type: 'post',
            dataType: 'json',
            data: {'jsonstr': jsonstr},
            async: false,
            success: function (result) {
                if (result.status) {
                    window.location = '${pageContext.request.contextPath}/blogtype/blog_type_list_vlew.html';
                } else {
                    layer.msg(result.msg)
                }
            },
            error: function () {
                alert("异常！");
            }
        });
    }

</script>
</body>
</html>